/**
 * Created by dell、 on 2017/10/26.
 */
function toAntiFraud(callLoanNid,borrowNid,realName,mobile,loanProduct,idNumber){
    console.log("toAntiFraud")
    layer.open({
        type: 1,
        skin: 'layui-layer-molv', //加上边框
        area: ['450px', '300px'], //宽高
        title:"提交反欺诈",
        anim: 4,
        btn: ['确定', '取消'],
        btnAlign: 'c',
        btn2: function(index, layero){
            layer.close(index);
        },
        yes : function(index, layero){
            var reg = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/;
            var Money =$("#caseMoney").val();
            if($.trim(Money)!=""){
                if (!reg.test(Money)){
                layer.msg("金额输入不正确",{icon:2});
                return;
            }
            }else{
                layer.msg("金额必须输入",{icon:0});
                return;
            }

            if ($.trim($("#reason").val())==""){
                layer.msg("提交原因必填",{icon:0});
                return;
            }
            $.ajax({
                type: "POST",
                dataType: "json",
                url: "blackList/commitFraud.do",
                data: {callLoanNid:callLoanNid,loanNo:borrowNid,name:realName,mobile: mobile,idNumber:idNumber,loanProduct:loanProduct,clueSource:3,clueType:$("#clueType").val(),channel:3,caseMoney:$("#caseMoney").val(),reason: $("#reason").val()},
                success: function (data) {
                    console.log("返回值data：" + data);
                        sweetAlert(data.msg);
                }
            });
            layer.close(index);


        },
        content: getAntiFraudPage() //这里content是一个DOM，注意：最好该元素要存放在body最外层，否则可能被其它的相对元素所影响
    });
}
function toBlackList(callLoanNid,realName,contIdCard,telephone,borrowName,repaymentId,productSource,userId,callUser){
    console.log("toBlackList")
    layer.open({
        type: 1,
        skin: 'layui-layer-molv', //加上边框
        area: ['450px', '300px'], //宽高
        title:"提交黑名单",
        anim: 4,
        btn: ['确定', '取消'],
        btnAlign: 'c',
        btn2: function(index, layero){
            layer.close(index);
        },
        yes : function(index, layero){
            if ($.trim($("#blackremark").val())==""){
                layer.msg("提交原因必填",{icon:0});
                return;
            }
            $.ajax({
                type: "POST",
                dataType: "json",
                url: "blackList/commitBlackList.do",
                data: {callLoanNid:callLoanNid,realName:realName,contIdCard: contIdCard,callUserId:callUser,telephone:telephone,borrowName:borrowName,callResult:$("#blackcallresult").val() ,remark: $("#blackremark").val(),repaymentId:repaymentId,productSource:productSource,userId:userId},
                success: function (data) {
                    sweetAlert(data.msg);
                }
            });
            layer.close(index);
        },
        content: getBlackListPage() //这里content是一个DOM，注意：最好该元素要存放在body最外层，否则可能被其它的相对元素所影响
    });
}
function getBlackListPage(){
    var value = $("input[name='callresulttypen']").val();
    var data =  $.dictionary(value).gets();
    var str= [];
    for(var o in data){
        str.push( '<option value="'+o+'">'+data[o]+'</option>');
    }
    var op = str.join('');
    return  [
        '<form id="blacklistform1" name = "blacklistform" class="form-horizontal m-t" style="margin-top: 25px;">',
        '<div class="form-group col-sm-12">',
        '<label class="col-sm-4 control-label">催收结果:</label>',
        '<div class="col-sm-8">',
        '<select class="form-control " name="blackcallresult" id="blackcallresult">',
         op,
        '</select>',
        '</div>',
        '</div>',
        '<div class="form-group col-sm-12">',
        '<label class="col-sm-4 control-label"> 提交原因:</label>',
        '<div class="col-sm-8">',
        '<textarea rows="5"  class="form-control" id="blackremark" name="blackremark" placeholder="200字以内" maxlength ="200" value="" style="resize: none"></textarea>',
        '</div>',
        '</div>',
        '</form>'
    ].join('');
}
function getAntiFraudPage() {
    return [
        '<form id="blacklistform1" name = "blacklistform" class="form-horizontal m-t" style="margin-top: 25px;">',
        '<div class="form-group col-sm-12">',
        '<label class="col-sm-4 control-label"> 欺诈类型:</label>',
        '<div class="col-sm-8">',
        '<select class="form-control " name="clueType" id="clueType">',
        '<option value="-1">其它</option>',
        '<option value="1">否认申请</option>',
        '<option value="2">手机号异常</option>',
        '<option value="3">身份证号码异常</option>',
        '<option value="4">联系信息异常</option>',
        '<option value="5">单位信息异常</option>',
        '<option value="6">财力信息异常</option>',
        '<option value="7">位置信息异常</option>',
        ' <option value="8">设备异常</option>',
        '</select>',
        '</div>',
        '</div>',
        '<div class="form-group col-sm-12">',
        '<label class="col-sm-4 control-label"> 涉案金额:</label>',
        '<div class="col-sm-8">',
        '<input id="caseMoney" type="text" class="form-control" name="caseMoney">',
        '</div>',
        '</div>',
        '<div class="form-group col-sm-12">',
        '<label class="col-sm-4 control-label"> 提交原因:</label>',
        '<div class="col-sm-8">',
        '<textarea rows="3"  class="form-control" id="reason" name="reason" placeholder="200字以内" maxlength ="200" value="" style="resize: none"></textarea>',
        '</div>',
        '</div>',
        '</form>'
    ].join('');
   }
    function updateStatus(userId,id,contStatus){
        console.log("修改联系人状态")
        layer.open({
            type: 1,
            skin: 'layui-layer-molv', //加上边框
            area: ['450px', '300px'], //宽高
            title:"修改联系人状态",
            anim: 4,
            btn: ['确定', '取消'],
            btnAlign: 'c',
            btn2: function(index, layero){
                layer.close(index);
            },
            yes : function(index, layero){
                $.ajax({
                    type: "POST",
                    dataType: "json",
                    url: "cuijisecondtimes/updateOldContract.do",
                    data: {userId:userId,id:id,contStatus:$("#linkManStatus").val()},
                    success: function (data) {
                        console.log("返回值data：" + data);
                         layer.msg(data.msg,{
                             icon:1,
                             time: 500,
                             skin: 'layui-layer-molv' //样式类名
                            ,closeBtn: 0
                        }, function(){
                             console.log("dd0刷新")
                             dd0()//刷新
                             layer.close(index);
                        });
                    }
                });
                console.log("layer.closeAll()")
                layer.close(index);
            },
            content: getUpdateStatustPage(contStatus) //这里content是一个DOM，注意：最好该元素要存放在body最外层，否则可能被其它的相对元素所影响
        });
    }
    function getUpdateStatustPage(contStatus) {
        return [
            '<script>$(function(){$("#linkManStatus").val('+contStatus+');});</script> ',
            '<form id="updateStatusform" name = "updateStatusform" class="form-horizontal m-t" style="margin-top: 25px;">',
            '<div class="form-group col-sm-12">',
            '<label class="col-sm-4 control-label"> 联系人状态:</label>',
            '<div class="col-sm-8">',
            '<select class="form-control " name="linkManStatus" id="linkManStatus">',
            '<option value="1">无效</option>',
            '<option value="0">有效</option>',
            '</select>',
            '</div>',
            '</div>',
            '</form>'
        ].join('');
    }

